package org.jivesoftware.spark.ui.transcript;

import java.awt.Color;
import java.util.Date;

import javax.swing.JPanel;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.StyleConstants;

import org.jivesoftware.spark.ui.ChatArea;
import org.jivesoftware.spark.ui.TranscriptWindow;
import org.jivesoftware.spark.util.log.Log;

/**
 * @author SidneyRen E-mail:SidneyRen@hotmail.com
 * @version create time：2010-10-25 下午05:24:12
 * 类说明
 */
public class MessageTranscriptPane extends TranscriptWindow {
	
	public MessageTranscriptPane(){

	}
	
	public JPanel createDateSeparator(Date date){
		return new JPanel(); 
	}
	
	/**
     * Create and insert a notification message. A notification message generally is a
     * presence update, but can be used for most anything related to the room.
     *
     * @param text       the text to insert.
     * @param bold       true to use bold text.
     * @param underline  true to have text underlined.
     * @param foreground the foreground color.
     */
    public synchronized void insertCustomText(String text, boolean bold, boolean underline, Color foreground) {
        try {
            // Agent color is always blue
            StyleConstants.setBold(styles, true);
            StyleConstants.setForeground(styles, foreground);
            final Document doc = getDocument();
            styles.removeAttribute("link");

            StyleConstants.setFontSize(styles,13);
            doc.insertString(doc.getLength(), "", styles);

            // Reset Styles for message
            StyleConstants.setBold(styles, bold);
            StyleConstants.setUnderline(styles, underline);
            StyleConstants.setForeground(styles, foreground);
            insertText("\n");
            setText(text);
//            setText("2010年10月25日 星期一");
            insertText("\n");
            StyleConstants.setUnderline(styles, false);
            StyleConstants.setForeground(styles, Color.black);
        }
        catch (BadLocationException ex) {
            Log.error("Error message.", ex);
        }
    }
}
